tool: End status line after pull
authorColin Walters <walters@verbum.org>
Thu, 3 Apr 2014 12:04:32 +0000 (08:04 -0400)
committerColin Walters <walters@verbum.org>
Thu, 3 Apr 2014 12:04:32 +0000 (08:04 -0400)
Otherwise we potentially get overlapped output.

src/ostree/ot-admin-builtin-switch.c
src/ostree/ot-admin-builtin-upgrade.c

index 6884d9f6c103258dfcdbbdcb21ca800503fa3588..ad652634d623871b3479089b07926541c6620ce9 100644 (file)
@@ -59,6 +59,7 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeSysroot *sysroot, GCancell
   gs_unref_object OstreeAsyncProgress *progress = NULL;
   gboolean changed;
   GSConsole *console = NULL;
+  gboolean in_status_line = FALSE;
   GKeyFile *old_origin;
   GKeyFile *new_origin = NULL;
 
@@ -113,6 +114,12 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeSysroot *sysroot, GCancell
       progress = ostree_async_progress_new_and_connect (ot_common_pull_progress, console);
     }
 
+  if (in_status_line)
+    {
+      gs_console_end_status_line (console, NULL, NULL);
+      in_status_line = FALSE;
+    }
+
   if (!ostree_sysroot_upgrader_pull (upgrader, 0, 0, progress, &changed,
                                      cancellable, error))
     goto out;
@@ -145,7 +152,7 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeSysroot *sysroot, GCancell
 
   ret = TRUE;
  out:
-  if (console)
+  if (in_status_line)
     gs_console_end_status_line (console, NULL, NULL);
   if (new_origin)
     g_key_file_unref (new_origin);
index 8d0c7cc9d38815b3ecfa7a1f212ab4b8299aeebd..46acfbc30e2b3fd166ff39197fdc15444030481b 100644 (file)
@@ -59,6 +59,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
   gs_unref_object OstreeDeployment *merge_deployment = NULL;
   gs_unref_object OstreeDeployment *new_deployment = NULL;
   GSConsole *console = NULL;
+  gboolean in_status_line = FALSE;
   gs_unref_object OstreeAsyncProgress *progress = NULL;
   gboolean changed;
   OstreeSysrootUpgraderPullFlags upgraderpullflags = 0;
@@ -81,6 +82,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
   if (console)
     {
       gs_console_begin_status_line (console, "", NULL, NULL);
+      in_status_line = TRUE;
       progress = ostree_async_progress_new_and_connect (ot_common_pull_progress, console);
     }
 
@@ -92,6 +94,12 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
                                      cancellable, error))
     goto out;
 
+  if (in_status_line)
+    {
+      gs_console_end_status_line (console, NULL, NULL);
+      in_status_line = FALSE;
+    }
+
   if (!changed)
     {
       g_print ("No update available.\n");
@@ -113,7 +121,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancel
 
   ret = TRUE;
  out:
-  if (console)
+  if (in_status_line)
     gs_console_end_status_line (console, NULL, NULL);
   if (context)
     g_option_context_free (context);